package com.example.postgresql.controller;

import com.example.postgresql.entity.Message;
import com.example.postgresql.entity.Test1;
import com.example.postgresql.service.MessageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * (Message)表控制层
 *
 * @author makejava
 * @since 2021-09-27 14:35:31
 */
@RestController
@RequestMapping("message")
public class MessageController {
    /**
     * 服务对象
     */
    @Resource
    private MessageService messageService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Message selectOne(Long id) {
        return this.messageService.queryById(id);
    }

    @GetMapping("queryAll")
    public Map<String, Object> queryAll(Message message) {
        return this.messageService.queryAll(message);
    }

    @PostMapping("new")
    public String addStudent(@RequestBody Message message) {
        this.messageService.insert(message);
        return "添加学生接口";
    }

}
